﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.ComponentModel;

namespace poco
{
    public abstract class PluralField
    {
        protected string value;

        [JsonProperty(PropertyName = "value")]
        public string Value
        {
            get { return value; }
            set
            {
                this.value = FormatValue(value);
            }
        }

        public virtual string FormatValue(string value)
        {
            return value;
        }

        [JsonProperty(PropertyName = "primary")]
        [DefaultValue(false)]
        public bool Primary { get; set; }

        public override bool Equals(object obj)
        {
            if (obj == null) return false;
            if (obj.GetType() != this.GetType()) return false;

            PluralField other = (PluralField)obj;

            if (!Object.Equals(this.Value, other.Value)) return false;
            if (!Object.Equals(this.Primary, other.Primary)) return false;

            return true;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
